import cv2
from matplotlib import pyplot as plt
import os, glob, shutil
import numpy as np
from scipy import stats
import pandas as pd
from pandas import DataFrame
import random
from os import path as osp
import xml.dom.minidom as minidom
import xml.etree.cElementTree as et
from numpy import random
import json



def data_multi(img):
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    out_v = cv2.Sobel(gray,-1,0,1)
    img[:,:,2] = out_v
    img[:,:,1] = out_v
    img[:,:,0] = gray
    return img


def vhfilp(img):
    ran = random.randint(4)
    if ran == 0:
        img = cv2.flip(img, 0)
        return img
    elif ran == 1:
        img = cv2.flip(img, 1)
        return img
    elif ran == 2:
        img = cv2.flip(cv2.flip(img, 0), 1)
        return img
    else:
        return img


def edge_move(img):
    ran = random.randint(6)
    rand = random.randint(1, 10)
    # print(rand)
    if ran == 0:
        img = img[rand:, :, :]
        return img
    elif ran == 1:
        img = img[:-rand, :, :]
        return img
    elif ran == 3:
        img = img[:, rand:, :]
        return img
    elif ran == 4:
        img = img[:, :-rand, :]
        return img
    else:
        return img
